-
Notifications
You must be signed in to change notification settings - Fork 760
feat: extensionless URL resolution in preview server #1824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: extensionless URL resolution in preview server #1824
Conversation
Links like <a href="about"> now resolve to about.html or about/index.html Fixes: Acode-Foundation#1739
This comment was marked as resolved.
This comment was marked as resolved.
Greptile SummaryAdded extensionless URL resolution to the preview server. When a request comes in without a file extension (e.g.,
The implementation is straightforward and solves the requested feature. Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant Server as Preview Server
participant EM as EditorManager
participant FS as FileSystem
Browser->>Server: GET /about (no extension)
Server->>Server: Extract reqPath = "about"
Server->>Server: Detect !ext && pathName
Note over Server: Try path.html first
Server->>EM: getFile("pathName/about.html")
alt File loaded and unsaved in editor
EM-->>Server: Return editor file
Server->>Server: sendHTML(file.session.getValue())
Server-->>Browser: 200 OK (HTML from editor)
else Not in editor
Server->>FS: fsOperation("pathName/about.html").exists()
alt about.html exists
FS-->>Server: true
Server->>Server: sendFileContent(htmlUrl, MIMETYPE_HTML)
Server-->>Browser: 200 OK (about.html)
else about.html not found
FS-->>Server: false
Note over Server: Try path/index.html fallback
Server->>FS: fsOperation("pathName/about/index.html").exists()
alt about/index.html exists
FS-->>Server: true
Server->>Server: sendFileContent(indexUrl, MIMETYPE_HTML)
Server-->>Browser: 200 OK (about/index.html)
else index.html not found
FS-->>Server: false
Server->>Server: error(reqId)
Server-->>Browser: 404 Not Found
end
end
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
Links like
<a href="about">now resolve toabout.htmlorabout/index.htmlFixes: #1739